package blazingbubble.gui.elements;




import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JPanel;

import blazingbubble.gui.INavigationButton;


public class MenuButton extends JButton implements INavigationButton {
	private static final long serialVersionUID = 7001811430691579006L;

	private Image backgroundImage = null;
	private JPanel destinationPanel = null;
	
	public MenuButton(String backgroundImagePath){
		try {
			this.backgroundImage = ImageIO.read(new File(backgroundImagePath));
		} 
		catch (IOException e) {
			e.printStackTrace();
			//TODO: shutdown program, add logger message
		}
		setUp();
	}

	@Override
	public void paint(Graphics graphics) {
		graphics.drawImage(backgroundImage, 0, 0, null);
	}

	private void setUp(){
		this.setSize(260, 55);
		this.setOpaque(false);
	}
	
	public void swapImage(String backgroundImagePath){
		try {
			this.backgroundImage = ImageIO.read(new File(backgroundImagePath));
		} 
		catch (IOException e) {
			e.printStackTrace();
			//TODO: shutdown program, add logger message
		}
		updateUI();
	}

	@Override
	public JPanel getDestinationPanel() {
		return destinationPanel;
	}
	
	@Override
	public void setDestinationPanel(JPanel destinationPanel) {
		this.destinationPanel = destinationPanel;		
	}
}
